package org.eclipseuseradmin.internal.ui;

import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.eclipseuseradmin.ui.IRoleRootDescriptor;

public class RoleRootElement implements IRoleRootDescriptor {

	private final static String ATT_ID = "id";
	
	private final static String ATT_NAME = "name";
	
	private final static String ATT_ICON = "icon";

	private final static String ATT_FILTER = "filter";

	private IConfigurationElement config;

	public RoleRootElement(
			IConfigurationElement config) {
		this.config = config;
	}

	public ImageDescriptor getImageDescriptor() {
		
		String pluginId = config.getContributor().getName();
		String imageFilePath = config.getAttribute(ATT_ICON);
		return AbstractUIPlugin.imageDescriptorFromPlugin(pluginId, imageFilePath);
	}

	public String getId() {
		return config.getAttribute(ATT_ID);
	}
	
	public String getName() {
		return config.getAttribute(ATT_NAME);
	}

	public String getFilter() {
		return config.getAttribute(ATT_FILTER);
	}
	
}
